function prop(e, a, t) {
  return a in e ? Object.defineProperty(e, a, {
    value: t,
    enumerable: !0,
    configurable: !0,
    writable: !0
  }) : e[a] = t, e;
}

var app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    url: "",
    shareMessage: {
      title: "",
      path: "",
      imageUrl: "",
      token: "",
    }
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // let url = decodeURIComponent(options.url) + "?" + Math.random();
    let url = decodeURIComponent(options.url);
	let token=wx.getStorageSync('token')
	
	options.url && this.setData({
	      url: url
	})
	this.getMemberInfo()
	// if(token){
	// 	url=url+'?token='+token;
	// }
 //    options.url && this.setData(prop({
 //      url: url
 //    }, "shareMessage.path", "/lionfish_comshop/pages/web-view?url=" + url));
 //    console.log("webviewUrl", this.data.url);
  },
  
  
  getMemberInfo: function() {
    var token = wx.getStorageSync('token');
	if(!token){
		wx.showToast({
		  icon: 'none',
		  title: '请先登录',
		})
		setTimeout(()=>{
			wx.navigateBack()
		},2000)
		return;
	}
	
    let that = this;
    app.util.request({
      url: 'entry/wxapp/user',
      data: {
        controller: 'user.get_user_token',
        token: token
      },
      dataType: 'json',
      success: function(res) {
		  console.log(res,'token_res')
        // wx.hideLoading();
        setTimeout(function(){ wx.hideLoading(); },1000);
        if (res.data.code == 0) {
			
			let url=that.data.url
			if(res.data.token){
				url=url+'?token='+res.data.token;
			}
			that.setData({
				token:res.data.token,
				url: url
			})
	
			console.log("webviewUrl", url);
			
  
        
        } else {
          //needAuth
          that.setData({
            needAuth: true
          })
          wx.setStorage({
            key: "member_id",
            data: null
          })
        }
      }
    })
  },
  

  getPostMessage: function (e) {
    var a = e.detail;
    console.log("收到的信息", a);
    var shareMessage = Object.assign({}, this.data.shareMessage, a.data[0]);
    this.setData({
      shareMessage: shareMessage
    }), wx.showShareMenu({
      withShareTicket: !0,
      success: function () {
        console.log("成功");
      },
      fail: function () {
        console.log("失败");
      }
    }), wx.updateShareMenu();
  },

  onPageLoad: function (e) {
    e.detail;
  },

  onPageError: function (e) {
    e.detail;
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    return console.log(this.data.shareMessage), Object.assign({}, this.data.shareMessage, {
      success: function () {
        console.log("share succeed");
      },
      error: function () {
        console.log("share failed");
      }
    });
  }
})